﻿using System.Text;
using System.Text.RegularExpressions;

using BodaNetCommunications.Commbase;
using BodaNetCommunications.CommBase.Interfaces;
using BodaNetCommunications.Nodes;
using BodaNetCommunications.Utilities.ComTypes;
using BodaNetCommunications.Utilities.Extensions;
using BodaNetCommunications.Utilities.LogHelper;
using BodaNetCommunications.Utilities.Results;
using BodaNetCommunications.Utilities.Tools;

namespace BodaNetCommunications.Cores
{
    public class CommReadWrite : ICommReadWrite
    {
        public ILogNet? LogNet { get; set; }
        public string? ConnectionId { get; set; }

        protected IByteTransform _byteTransform = new ByteTransformBase();

        //
        // 摘要:
        //     一个字单位的数据表示的地址长度，西门子为2，三菱，欧姆龙，modbusTcp就为1，AB PLC无效
        //     The address length represented by one word of data, Siemens is 2, Mitsubishi,
        //     Omron, modbusTcp is 1, AB PLC is invalid
        //
        // 言论：
        //     对设备来说，一个地址的数据对应的字节数，或是1个字节或是2个字节，4个字节，通常是这四个选择，当设置为0时，则表示4字节的地址长度信息
        //     For the device, the number of bytes corresponding to the data of an address,
        //     either 1 byte or 2 bytes, 4 bytes, usually these four choices, when set to 0,
        //     it means 4 words Section address length information
        protected ushort WordLength { get; set; } = 0;


        //
        // 摘要:
        //     一个字单位的数据表示的地址长度，西门子为2，三菱，欧姆龙，modbusTcp就为1，AB PLC无效
        //     The address length represented by one word of data, Siemens is 2, Mitsubishi,
        //     Omron, modbusTcp is 1, AB PLC is invalid
        //
        // 参数:
        //   address:
        //     读取的设备的地址信息
        //
        //   length:
        //     读取的数据长度信息
        //
        //   dataTypeLength:
        //     数据类型的字节长度信息，比如short, 就是2，int,float就是4
        //
        // 言论：
        //     对设备来说，一个地址的数据对应的字节数，或是1个字节或是2个字节，通常是这两个选择。
        //     当前也可以重写来根据不同的地址动态控制不同的地址长度，比如有的地址是一个地址一个字节的，有的地址是一个地址两个字节的
        protected virtual ushort GetWordLength(string address, int length, int dataTypeLength)
        {
            if (WordLength == 0)
            {
                int num = length * dataTypeLength * 2 / 4;
                return (ushort)((num == 0) ? 1 : ((ushort)num));
            }

            var len = (ushort)(WordLength * length * dataTypeLength);
            return len;
        }

        public virtual Dictionary<Type, DataType> TypeDateDic { get; set; } = new()
        {
            { typeof(bool), DataType.@bool},
            { typeof(byte), DataType.@byte},
            { typeof(short), DataType.@short},
            { typeof(ushort), DataType.@ushort},
            { typeof(int), DataType.@int},
            { typeof(uint), DataType.@uint},
            { typeof(float), DataType.@float},
            { typeof(double), DataType.@double},
            { typeof(string), DataType.@string},
        };

        public virtual BodaResult ReadByAddress(string address, ushort length = 1)
        {
            BodaResult bodaResult = new BodaResult();
            var res = _byteTransform.AnalysyseAddresType(ref address, out var typeTemp);
            if (!res)
            {
                bodaResult.IsSuccess = false;
                bodaResult.Message = $"根据地址{address}，未获取到对应的数据类型，或者未实现对应的转换方法";
                return bodaResult;
            }
            DataType dataType = TypeDateDic[typeTemp];
            return Read(address, dataType, length);
        }

        public BodaResult ReadNodes(List<RequestNode> nodes, Action<List<RequestNode>>? inputCallback = null, CancellationToken token = default)
        {
            BodaResult bodaResult = new BodaResult();
            if (nodes.Count == 0)
            {
                bodaResult.IsSuccess = false;
                bodaResult.Message = "nodes is empty";
                return bodaResult;
            }

            var validCount = 0;
            foreach (var item in nodes)
            {
                if (token.IsCancellationRequested)
                {
                    bodaResult.IsSuccess = false;
                    bodaResult.Message = "CancellationTokenSource is triggered!";
                    return bodaResult;
                }
                if (string.IsNullOrEmpty(item.NodeAddress))
                {
                    item.ReadVarValue = string.Empty;
                    continue;
                }

                if (item.PlcDataFormat == null)
                {
                    item.ReadVarValue = string.Empty;
                    continue;
                }
                BodaResult res = Read(item.NodeAddress, (DataType)item.PlcDataFormat, (ushort)item.Count);
                if (res.IsSuccess)
                {
                    item.ReadVarValue = res.Result;
                    validCount++;
                }
                else
                {
                    item.ReadVarValue = string.Empty;
                }
            }

            inputCallback?.Invoke(nodes);
            bodaResult.IsSuccess = validCount == nodes.Count;
            bodaResult.Message = bodaResult.IsSuccess ? "读取成功" : $"读取OK数量不一致-> 总数量{nodes.Count}，实际成功数量{validCount}";
            return bodaResult;
        }

        public BodaResult Read(string address, DataType dataType, ushort length = 1)
        {
            BodaResult bodaResult = new BodaResult();
            switch (dataType)
            {
                case DataType.@bit:
                case DataType.@bool:
                    {
                        var res = ReadBool(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@byte:
                    {
                        var res = Read(address, 1);
                        if (res.IsSuccess && res.Content != null && res.Content.Length == 1)
                        {
                            bodaResult.Result = res.Content[0];
                            bodaResult.IsSuccess = true;
                        }
                        else
                        {
                            bodaResult.IsSuccess = false;
                        }

                        bodaResult.Message = res.Message;
                    }
                    break;
                case DataType.@short:
                    {
                        var res = ReadInt16(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@word:
                case DataType.@ushort:
                    {
                        var res = ReadUInt16(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                // 默认32位，西门子的int位short类型
                case DataType.@int:
                // 西门子的DInt就是32位, int为16位
                case DataType.@dint:
                    {
                        var res = ReadInt32(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@uint:
                    {
                        var res = ReadUInt32(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@float:
                case DataType.@real:
                    {
                        var res = ReadFloat(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@double:
                    {
                        var res = ReadDouble(address);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content;
                    }
                    break;
                case DataType.@decimal:
                    break;
                case DataType.@long:
                    break;
                case DataType.@ulong:
                    break;
                case DataType.@string:
                    {
                        var res = ReadString(address, length);
                        bodaResult.IsSuccess = res.IsSuccess;
                        bodaResult.Message = res.Message;
                        bodaResult.Result = res.Content ?? string.Empty;
                    }
                    break;
                case DataType.@bytearray:
                    break;


                default:
                    break;
            }
            return bodaResult;
        }

        public virtual BodaResult<byte[]> Read(string address, ushort length)
        {
            return new BodaResult<byte[]>(StringResources.Language.NotSupportedFunction);
        }

        /// <summary>
        /// 通过地址解析出数据类型，并读取数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public virtual BodaResult Read(string address, string dataType, ushort length = 1)
        {
            BodaResult bodaResult = new BodaResult();
            // 获取地址类型
            DataType dataTypeRes = Enum.TryParse(typeof(DataType), dataType, out var dataTypeTemp) ? (DataType)dataTypeTemp : DataType.none;
            if (dataTypeRes == DataType.none)
            {
                bodaResult.IsSuccess = false;
                bodaResult.Message = $"{dataType}转换为类型{nameof(DataType)}失败";
                return bodaResult;
            }
            // 读取数据
            var resRead = Read(address, dataTypeRes, length);
            // 数据转换
            return resRead;
        }

        public virtual BodaResult<T> Read<T>() where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<byte[]>> ReadAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<T>> ReadAsync<T>() where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<bool[]> ReadBool(string address, ushort length)
        {
            var res = Read(address, length);
            res.Message += $" -->【ReadBool】address[{address}], length: {length}";

            var resData = ByteTransformHelper.GetResultFromBytes(res, (byte[] m) => _byteTransform.TransBool(m, 0, length));
            return resData;
        }

        public virtual BodaResult<bool> ReadBool(string address)
        {
            var res = ReadBool(address, 1);
            res.Message += $" -->【ReadBool】address[{address}]";

            return ByteTransformHelper.GetResultFromArray(res);
        }

        public virtual Task<BodaResult<bool[]>> ReadBoolAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<bool>> ReadBoolAsync(string address)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<T> ReadCustomer<T>(string address) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<T> ReadCustomer<T>(string address, T obj) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<T>> ReadCustomerAsync<T>(string address) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<T>> ReadCustomerAsync<T>(string address, T obj) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<double> ReadDouble(string address)
        {
            var res = ReadDouble(address, 1);
            res.Message += $" -->【ReadDouble】address[{address}]";

            return ByteTransformHelper.GetResultFromArray(res);
        }

        public virtual BodaResult<double[]> ReadDouble(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, GetWordLength(address, length, 8)), (byte[] m) => _byteTransform.TransDouble(m, 0, length));
        }

        public virtual Task<BodaResult<double>> ReadDoubleAsync(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<double[]>> ReadDoubleAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public BodaResult<float> ReadFloat(string address)
        {
            var res = ReadFloat(address, 1);
            res.Message += $" -->【ReadFloat】address[{address}]";


            return ByteTransformHelper.GetResultFromArray(res);

        }

        public virtual BodaResult<float[]> ReadFloat(string address, ushort length)
        {
            return ByteTransformHelper.GetResultFromBytes(Read(address, GetWordLength(address, length, 4)), (byte[] m) => _byteTransform.TransSingle(m, 0, length));

        }

        public virtual Task<BodaResult<float>> ReadFloatAsync(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<float[]>> ReadFloatAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }


        public virtual BodaResult<short> ReadInt16(string address)
        {
            var res = ReadInt16(address, 1);
            res.Message += $" -->【ReadInt16】address[{address}]";

            return ByteTransformHelper.GetResultFromArray(res);
        }

        public virtual BodaResult<short[]> ReadInt16(string address, ushort length)
        {
            var words = GetWordLength(address, length, 2);
            return ByteTransformHelper.GetResultFromBytes(Read(address, words), (byte[] m) => _byteTransform.TransInt16(m, 0, length));
        }

        public virtual Task<BodaResult<short>> ReadInt16Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<short[]>> ReadInt16Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<int> ReadInt32(string address)
        {
            var res = ReadInt32(address, 1);
            res.Message += $" -->【ReadInt32】address[{address}]";

            return ByteTransformHelper.GetResultFromArray(res);
        }

        public virtual BodaResult<int[]> ReadInt32(string address, ushort length)
        {
            var words = GetWordLength(address, length, 4);
            return ByteTransformHelper.GetResultFromBytes(Read(address, words), (byte[] m) => _byteTransform.TransInt32(m, 0, length));
        }

        public virtual Task<BodaResult<int>> ReadInt32Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<int[]>> ReadInt32Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<long> ReadInt64(string address)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<long[]> ReadInt64(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<long>> ReadInt64Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<long[]>> ReadInt64Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<string> ReadString(string address, ushort length)
        {
            var res =  ReadString(address, length, Encoding.UTF8);
            res.Content = res.Content?.RemoveControlChars();
            return res;
        }

        public virtual BodaResult<string> ReadString(string address, ushort length, Encoding encoding)
        {
            // 读取字符串的地址，地址中含有不是DBB的全部替换为DBB
            if (address.ToLowerInvariant().Contains("db"))
            {
                string[] arrays = address.Split('.');
                var addrType = arrays[1].Substring(2, 1);
                if (addrType.ToLowerInvariant() != "b")
                {
                    var charArray = arrays[1].ToCharArray();
                    charArray[2] = 'B';
                    arrays[1] = new string(charArray);
                }
                address = $"{arrays[0]}.{arrays[1]}";
            }
            var words = GetWordLength(address, length, 1);

            var readResult = Read(address, words);
            var res = ByteTransformHelper.GetResultFromBytes(readResult, (byte[] m) => _byteTransform.TransString(m, encoding));
            return res;
        }

        public virtual Task<BodaResult<string>> ReadStringAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<string>> ReadStringAsync(string address, ushort length, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<T> ReadStruct<T>(string address, ushort length) where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<T>> ReadStructAsync<T>(string address, ushort length) where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<ushort> ReadUInt16(string address)
        {
            var resData = ReadUInt16(address, 1);
            resData.Message += $" -->【ReadUInt16】address[{address}]";

            var res = ByteTransformHelper.GetResultFromArray(resData);
            return res;
        }

        public virtual BodaResult<ushort[]> ReadUInt16(string address, ushort length)
        {
            var words = GetWordLength(address, length, 2);
            var res = ByteTransformHelper.GetResultFromBytes(Read(address, words), (byte[] m) => _byteTransform.TransUInt16(m, 0, length));
            return res;
        }

        public virtual Task<BodaResult<ushort>> ReadUInt16Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<ushort[]>> ReadUInt16Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<uint> ReadUInt32(string address)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<uint[]> ReadUInt32(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<uint>> ReadUInt32Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<uint[]>> ReadUInt32Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<ulong> ReadUInt64(string address)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<ulong[]> ReadUInt64(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<ulong>> ReadUInt64Async(string address)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<ulong[]>> ReadUInt64Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, bool waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, short waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, ushort waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, int waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, uint waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, long waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult<TimeSpan> Wait(string address, ulong waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, bool waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, short waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, ushort waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, int waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, uint waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, long waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<TimeSpan>> WaitAsync(string address, ulong waitValue, int readInterval, int waitTimeout)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, byte[] value)
        {
            return new BodaResult<byte[]>(StringResources.Language.NotSupportedFunction);
        }

        public virtual BodaResult Write(string address, bool[] value)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, bool value)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, short value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, short[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, ushort value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, ushort[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, int value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, int[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, uint value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, uint[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, long value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, long[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, ulong value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, ulong[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, float value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, float[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, double value)
        {
            return Write(address, _byteTransform.AnalysyseAddresAdndGetBytes(address, value));
        }

        public virtual BodaResult Write(string address, double[] values)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, string value)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, string value, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, string value, int length)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write(string address, string value, int length, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult Write<T>(T data) where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, byte[] value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, bool[] value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, bool value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, short value)
        {
            var bytes = _byteTransform.TransByte(value);
            return WriteAsync(address, bytes);
        }

        public virtual Task<BodaResult> WriteAsync(string address, short[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, ushort value)
        {
            var bytes = BitConverter.GetBytes(value);
            return WriteAsync(address, bytes);
        }

        public virtual Task<BodaResult> WriteAsync(string address, ushort[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, int value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, int[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, uint value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, uint[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, long value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, long[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, ulong value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, ulong[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, float value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, float[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, double value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, double[] values)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, string value)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, string value, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, string value, int length)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync(string address, string value, int length, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteAsync<T>(T data) where T : class, new()
        {
            throw new NotImplementedException();
        }

        public virtual BodaResult WriteCustomer<T>(string address, T value) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult> WriteCustomerAsync<T>(string address, T value) where T : IDataTransfer, new()
        {
            throw new NotImplementedException();
        }



        public virtual Task<BodaResult> SendMsgAsync(string msg, int timeout = 1500)
        {
            throw new NotImplementedException();
        }

        public virtual Task<BodaResult<string>> ReceiveMsgAsync(int timeout = 2000, int bytesLen = 1024, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }


    }
}
